#define _CRT_SECURE_NO_WARNINGS 1
#include <vector>
#include <unordered_set>
#include <iostream>
using namespace std;
class Solution {
public:
    int longestConsecutive(vector<int>& nums)
    {
        unordered_set<int> un_set;
        for (const auto& a : nums)
        {
            un_set.insert(a);
        }
        int max = 0;
        for (const auto& a : un_set)
        {
            if (un_set.find(a - 1) != un_set.end())
                continue;
            int len = 0;
            int x = a;
            cout << "x=" << x << endl;
            while (un_set.find(x) != un_set.end())
            {
                ++len;
                ++x;
            }
            if (len > max)
            {
                max = len;
            }
        }
        return max;
    }
};